module Logins exposing (..)

import Logins.UserLogin as UserLogin
import Logins.ShopLogin as ShopLogin
import Html exposing (Html, a, button, code, div, h1, li, text, ul, input)

type Msg
 = UserLoginMsg UserLogin.Msg
 | ShopLoginMsg ShopLogin.Msg

type Model = Model UserLogin.Model ShopLogin.Model

initModel : Model
initModel =
 Model UserLogin.initModel ShopLogin.initModel

view : Model -> Html Msg
view (Model user shop) =
 div []
  [ Html.map UserLoginMsg (UserLogin.view user)
  , Html.map ShopLoginMsg (ShopLogin.view shop)
  ]

update : Msg -> Model -> (Model, Cmd Msg)
update msg (Model userLoginModel shopLoginModel) =
 case msg of
  UserLoginMsg msg ->
   let (newUserModel,cmd) = UserLogin.update msg userLoginModel
   in (Model newUserModel shopLoginModel,Cmd.map UserLoginMsg cmd)
 
  ShopLoginMsg msg ->
   let (newShopModel,cmd) = ShopLogin.update msg shopLoginModel
   in (Model userLoginModel newShopModel,Cmd.map ShopLoginMsg cmd)
          